package com.vanke.vms.management.action;

import java.util.List;

import com.vanke.vms.common.action.BaseAction;
import com.vanke.vms.common.domain.User;
import com.vanke.vms.management.service.ManageActivityService;

public class ManageActivityAction extends BaseAction {

	private static final long serialVersionUID = -5628186802266995839L;

	private ManageActivityService manageActivityService;

	private int isexist;

	private String pname;

	private String cname;

	private List<String> list1;

	private List<String> list2;

	private List<String> list3;

	private List<String> list4;

	private List<String> list5;

	private List<String> list6;

	private int role;

	public String loadActivityList() {
		User curUser = (User)session.get("user");
		if(curUser == null)
			return LOGIN;
		if(curUser.getGrade() == 2)
			role = 2;
		else if(curUser.getGrade() == 1)
			role = 1;
		else if(curUser.getGrade() == 0)
			role = 0;
		
		List<List<String>> allList = manageActivityService.loadActivityList();
		list1 = allList.get(0);
		list2 = allList.get(1);
		list3 = allList.get(2);
		list4 = allList.get(3);
		list5 = allList.get(4);
		list6 = allList.get(5);
		return "loaded";
	}

	public String addActivity() {
		isexist = 0;
		if (manageActivityService.addActivity(pname, cname).equals("")){
			isexist = 1;
			return "exist";
		}
		else
			return SUCCESS;
	}
	
	public String noUse(){
		return SUCCESS;
	}


	public String removeActivity() {
		manageActivityService.removeActivity(pname, cname);
		return SUCCESS;
	}

	// ////////////////////////////////////////
	
	public int getRole() {
		return role;
	}

	public void setRole(int role) {
		this.role = role;
	}

	public int getIsexist() {
		return isexist;
	}

	public void setIsexist(int isexist) {
		this.isexist = isexist;
	}

	public String getPname() {
		return pname;
	}

	public void setPname(String pname) {
		this.pname = pname;
	}

	public String getCname() {
		return cname;
	}

	public void setCname(String cname) {
		this.cname = cname;
	}

	public ManageActivityService getManageActivityService() {
		return manageActivityService;
	}

	public void setManageActivityService(
			ManageActivityService manageActivityService) {
		this.manageActivityService = manageActivityService;
	}

	public List<String> getList1() {
		return list1;
	}

	public void setList1(List<String> list1) {
		this.list1 = list1;
	}

	public List<String> getList2() {
		return list2;
	}

	public void setList2(List<String> list2) {
		this.list2 = list2;
	}

	public List<String> getList3() {
		return list3;
	}

	public void setList3(List<String> list3) {
		this.list3 = list3;
	}

	public List<String> getList4() {
		return list4;
	}

	public void setList4(List<String> list4) {
		this.list4 = list4;
	}

	public List<String> getList5() {
		return list5;
	}

	public void setList5(List<String> list5) {
		this.list5 = list5;
	}
	
	public List<String> getList6() {
		return list6;
	}

	public void setList6(List<String> list6) {
		this.list6 = list6;
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
}
